#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json
import os

import numpy as np

from loguru import logger
import matlab.engine
from PIL import Image

# 测试dict传入matlab函数, matlab中为一个结构体

if __name__ == '__main__':
#################################################################
# define a global single variable
    matlab_eng = matlab.engine.start_matlab()
    matlab_scripts_path = os.getcwd() + "/matlab_scripts/image_signal_analysis"
    matlab_eng.cd(matlab_scripts_path)

    #pai_analysis = PAIAnalysis()
    #pa_image_list = []
    example_img_path = os.getcwd() + "/matlab_scripts/const_file"

    probe_param = {"Nelements":64, "fc":6, "pitch":0.025, "width":0.05}


#     1. PARAM.Nelements: number of elements in the transducer array
# 2. PARAM.fc: center frequency (in Hz)
# 3. PARAM.pitch: element pitch (in m)
# 4. PARAM.width: element width (in m)
# 5. PARAM.kerf: kerf width (in m)
# 6. PARAM.bandwidth: 6-dB pulse-echo fractional bandwidth (in %)
# 7. PARAM.radius: radius of curvature (in m, Inf for a linear array)
# 8. PARAM.focus: elevation focus (in m)
# 9. PARAM.height: element height (in m)

    bin_file_path = 'D:\Project\Data\YCS-牛长骨-1-PL-400-2023-10-20-06-46-00\2023-10-20-06-51-25/Rawdata_FPGA1_Frame9.bin'
    acq_parameter_file_path = "D:/"
    save_path = 'D:/Project/Data/'

    logger.debug("input arguments of matlab function: USPArecon. probe_param:{0}", probe_param)

    path = matlab_eng.USPArecon(bin_file_path, acq_parameter_file_path, save_path, probe_param, 0, "DAS", 14, 1500)